package com.chatplus.application.validation;

import cn.hutool.core.util.PhoneUtil;
import com.chatplus.application.web.verification.domain.model.VerificationErrorCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import static cn.hutool.core.lang.Assert.isTrue;

@Service
public class CaptchaValidation {

    public void smsCaptchaValidator(String phoneNumber) {
        isTrue(StringUtils.isNotBlank(phoneNumber), VerificationErrorCode.MOBILE_PHONE_REQUIRED);
        isTrue(PhoneUtil.isMobile(phoneNumber), VerificationErrorCode.MOBILE_PHONE_INVALID);
    }
}
